import {StateBusInterface} from "db://assets/Script/State/interface/StateBusInterface";
import {StateEnum} from "db://assets/Script/Enums/StateEnum";
import {Actor} from "db://assets/Script/Actor/Actor";
import {Animation} from "cc"

export abstract class ActorState implements StateBusInterface<StateEnum> {
    stateEnum: StateEnum
    actor: Actor
    animation: Animation

    constructor(stateEnum: StateEnum, actor: Actor) {
        this.stateEnum = stateEnum
        this.actor = actor
        this.animation = actor.animation
    }

    /**
     * 执行当前状态逻辑
     */
    onEnter():void {
    }

    /**
     * 删除状态
     */
    onDestroy():void {
    }

    /**
     * 退出状态
     */
    onExit():void {
    }

    /**
     * 是否可以进入当前状态
     * @param to 即将转换的状态
     */
    canTransition(to: StateEnum): boolean {
        return true
    }

    /**
     * 更新当前状态 持续执行当前状态
     * @param deltaTime 运行时间
     */
    update(deltaTime: number): void {
    }
}
